package com.hyc;

import com.hyc.pojo.Task;
import com.hyc.proxy.ServiceProxy;
import com.hyc.service.TaskService;

import java.util.concurrent.TimeUnit;

/**
 * @author 冷环渊
 * @date 2025/6/6 19:24
 * @description clientA
 */
public class clientA {
    public static void main(String[] args) {
        ServiceProxy proxy = new ServiceProxy();
        TaskService taskService = proxy.getProxy(TaskService.class);
        for (int i = 1; i <= 3; i++) {
            if (i % 2 == 0) {
                try {
                    TimeUnit.SECONDS.sleep(3);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            int finalI = i;
            new Thread(() -> {
                try {
                    Task user = taskService.getTaskById(finalI);
                    System.out.println("获取到任务=" + user.toString());
                } catch (NullPointerException e) {
                    e.printStackTrace();
                }
            }).start();
        }
//        taskService.insertTaskId(new Task(1, "今天需要好好吃饭", true));
//        System.out.println("rpc请求的结果: " + taskService.getTaskById(1));
    }
}
